package com.wang.tool.util;

import java.io.Serializable;

public class ScanParam implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * lastValue
     * can be null
     */
    private Object lastValue;


    /**
     * >0
     */
    private int pageSize;

    public static ScanParam build(Object lastValue, Integer pageSize) {
        if (pageSize==null || pageSize<=0) {
            throw new IllegalArgumentException("pageSize can not be null");
        }

        ScanParam pageParam = new ScanParam();
        pageParam.setLastValue(lastValue);
        pageParam.setPageSize(pageSize);
        return pageParam;
    }

    public boolean judgeIsValid(){
        return pageSize > 0;
    }

    public Object getLastValue() {
        return lastValue;
    }

    public void setLastValue(Object lastValue) {
        this.lastValue = lastValue;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
